package ptapart3;

import java.util.Arrays;
import java.util.Scanner;

public class QuestionFive {

	public static void main(String[] args) {

		int flag = 0;

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();

		int m = in.nextInt();

		PersonOverride[] person1 = new PersonOverride[n];

		PersonOverride[] person2 = new PersonOverride[m];

		for (int i = 0; i < n; i++) {

			person1[i] = new PersonOverride();

		}

		for (int i = 0; i < person2.length; i++) {
			PersonOverride tempperson = new PersonOverride(in.next(),
					in.nextInt(),

					in.nextBoolean());

			if (i == 0)

			{

				person2[i] = tempperson;

				continue;

			}

			for (int j = 0; j < i; j++) {

				if (person2[j] != null)

					if (tempperson.equals(person2[j]))

						flag = 1;

			}

			if (flag == 0)

			{

				person2[i] = tempperson;

			}

			flag = 0;

		}

		for (int i = 0; i < person1.length; i++) {

			System.out.println(person1[i]);

		}

		int count = 0;

		for (int i = 0; i < person2.length; i++) {

			if (person2[i] != null) {

				System.out.println(person2[i]);

				count++;
			}

		}

		System.out.println(count);

		System.out.println(Arrays.toString(PersonOverride.class
				.getConstructors()));

	}

}

class PersonOverride {
	private String name;
	private int age;
	private boolean gender;

	public PersonOverride() {
		this("default", 1, true);
	}

	public PersonOverride(String name, int age, boolean gender) {
		this.name = name;
		this.age = age;
		this.gender = gender;
	}

	@Override
	public String toString() {
		return name + "-" + age + "-" + gender;
	}

	public boolean euquals(PersonOverride people) {
		if (this.name.equals(people.name) && this.age == people.age
				&& this.gender == people.gender)
			return true;
		return false;
	}
}